//
//  ViewController.m
//  RACExamale
//
//  Created by cym_bj on 2017/11/29.
//  Copyright © 2017年 com.cym. All rights reserved.
//

#import "ViewController.h"
#import "A_1ViewController.h"
#import "A_2ViewController.h"
#import "A_3ViewController.h"
#import "A_4ViewController.h"
#import "B_1ViewController.h"
#import "B_2ViewController.h"
#import "C_1ViewController.h"
#import "C_2ViewController.h"
#import "C_3ViewController.h"
#import "C_4ViewController.h"
#import "C_5ViewController.h"
#import "D_1ViewController.h"
#import "D_2ViewController.h"
#import "D_3ViewController.h"

#import "E_1ViewController.h"
#import "E_2ViewController.h"
#import "E_3ViewController.h"

#import "F_1ViewController.h"
#import "F_2ViewController.h"
#import "F_3ViewController.h"

@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong)NSArray *datas;

@end

@implementation ViewController

-(NSArray *)datas
{
    
    if (_datas==nil) {
        
        
        _datas=@[@[@"RAC初体验、RACSignal",@"取消订阅（RACDisposable）",@"RACSubject",@"RACReplaySubject"],@[@"集合",@"常用的宏"],@[@"按钮点击、代理",@"代替KVO",@"通知",@"监听文本框",@"计时器"],@[@"liftSelector",@"RACMulticastConnection(连接)",@"RACCommand(命令)"],@[@"映射(flattenMap,Map)",@"组合(combineLatest、zipWith,merge,then,concat)",@"过滤"],@[@"登录界面（无设计模式）",@"登录界面(用设计模式)",@"网络请求"]];
        
    }
    return _datas;
    
    
    
}

-(void)viewDidLoad
{
    [super viewDidLoad];
    
    self.navigationItem.title=@"例子";
    
    
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return self.datas.count;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
   return  [self.datas[section] count];
    
}

-(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    if (section==0) {
        
        return @"基本使用";
    }
    else if (section==1)
    {
        
        return @"集合和宏";
        
    }
    
    return @"常用操作";
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *ID=@"ID";
    
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:ID];
    
    if (cell==nil)
    {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.textLabel.font=[UIFont systemFontOfSize:15];
        
    }
    
    cell.textLabel.text=self.datas[indexPath.section][indexPath.row];
    
    return cell;
    
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    
    if (indexPath.section==0) {
        
        
        if (indexPath.row==0) {
            
            A_1ViewController *a1VC=[[A_1ViewController alloc]init];
            [self.navigationController pushViewController:a1VC animated:YES];
            
        }
        //取消订阅（RACDisposable）
        else if (indexPath.row==1)
        {
            A_2ViewController *a2VC=[[A_2ViewController alloc]init];
            [self.navigationController pushViewController:a2VC animated:YES];
            
        }
        //RACSubject
        else if (indexPath.row==2)
        {
            A_3ViewController *a3VC=[[A_3ViewController alloc]init];
            [self.navigationController pushViewController:a3VC animated:YES];
        }
        
        //RACReplaySubject
        else if (indexPath.row==3)
        {
            A_4ViewController *a4VC=[[A_4ViewController alloc]init];
            [self.navigationController pushViewController:a4VC animated:YES];
        }
    
        
    }
    else if (indexPath.section==1)
    {
        
        //集合
        if (indexPath.row==0) {
            
            B_1ViewController *b1VC=[[B_1ViewController alloc]init];
            [self.navigationController pushViewController:b1VC animated:YES];
            
        }
        else if (indexPath.row==1)
        {
            B_2ViewController *b2VC=[[B_2ViewController alloc]init];
            [self.navigationController pushViewController:b2VC animated:YES];
        }
        
        
        
    }
    
    else if (indexPath.section==2)
    {
        
        if (indexPath.row==0) {
            
            C_1ViewController *c1VC=[[C_1ViewController alloc]init];
            [self.navigationController pushViewController:c1VC animated:YES];
            
        }
        else if (indexPath.row==1)
        {
            C_2ViewController *c2VC=[[C_2ViewController alloc]init];
            [self.navigationController pushViewController:c2VC animated:YES];
        }
        else if (indexPath.row==2)
        {
            C_3ViewController *c3VC=[[C_3ViewController alloc]init];
            [self.navigationController pushViewController:c3VC animated:YES];
        }
        else if (indexPath.row==3)
        {
            C_4ViewController *c4VC=[[C_4ViewController alloc]init];
            [self.navigationController pushViewController:c4VC animated:YES];
        }
        else if (indexPath.row==4)
        {
            C_5ViewController *c5VC=[[C_5ViewController alloc]init];
            [self.navigationController pushViewController:c5VC animated:YES];
        }
        

    }
    else if (indexPath.section==3)
    {
        
        if (indexPath.row==0) {
            
            D_1ViewController *d1VC=[[D_1ViewController alloc]init];
            [self.navigationController pushViewController:d1VC animated:YES];
            
        }
        else if (indexPath.row==1)
        {
            D_2ViewController *d2VC=[[D_2ViewController alloc]init];
            [self.navigationController pushViewController:d2VC animated:YES];
            
        }
        else if (indexPath.row==2)
        {
            D_3ViewController *d3VC=[[D_3ViewController alloc]init];
            [self.navigationController pushViewController:d3VC animated:YES];
            
        }
        
    }
    
    else if (indexPath.section==4)
    {
        if (indexPath.row==0) {
            
            E_1ViewController *e1VC=[[E_1ViewController alloc]init];
            [self.navigationController pushViewController:e1VC animated:YES];
        }
        else if (indexPath.row==1)
        {
            E_2ViewController *e2VC=[[E_2ViewController alloc]init];
            [self.navigationController pushViewController:e2VC animated:YES];
            
        }
        
        else if (indexPath.row==2)
        {
            E_3ViewController *e3VC=[[E_3ViewController alloc]init];
            [self.navigationController pushViewController:e3VC animated:YES];
            
        }
        
    }
    else if (indexPath.section==5)
    {
        
        if (indexPath.row==0) {
            
            F_1ViewController *f1VC=[[F_1ViewController alloc]init];
            [self.navigationController pushViewController:f1VC animated:YES];
        }
        else if (indexPath.row==1)
        {
            F_2ViewController *f2VC=[[F_2ViewController alloc]init];
            [self.navigationController pushViewController:f2VC animated:YES];
        }
        else if (indexPath.row==2)
        {
            F_3ViewController *f3VC=[[F_3ViewController alloc]init];
            [self.navigationController pushViewController:f3VC animated:YES];
        }
        
    }
    
    
    
}





@end
